﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Prison.Defence.Content.Pipleline.DataTypes;
using System.Xml;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate;
using Microsoft.Xna.Framework;

namespace LevelEditor
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            SceneDefinition scene = new SceneDefinition();

            scene.Models.Add(1, new ModelDefinition()
            {
                ModelAssetName = @"Models\Fence1",
                Rotation = Vector3.Zero,
                Scale = 0.1f
            });

            scene.Models.Add(2, new ModelDefinition()
            {
                ModelAssetName = @"Models\Fence2",
                Rotation = Vector3.Zero,
                Scale = 1f,
            });

            for (int i = -20; i < 20; i += 10)
            {
                scene.ModelInstances.Add(new ModelInstanceDefinition()
                {
                    ModelDefReference = 1,
                    Position = new Vector3(i, 0, 0),
                    Rotation = Vector3.Zero,
                    Scale = 1f
                });
            }

            List<ModifierDefinition> modifiers = new List<ModifierDefinition>() { 
                new RotationModifierDefinition() { Position = Vector3.One, Rotation = Vector3.Up } };

            scene.Lights.Add(new LightDefinition() { 
                Direction = Vector3.Forward, Position = Vector3.One, Type = LightType.Directional, Color = Color.Red,
                Modifiers = modifiers
            });

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            using (XmlWriter writer = XmlWriter.Create("..\\..\\..\\Prison Defence\\Prison DefenceContent\\Levels\\LevelDesc.xml", settings))
            {
                IntermediateSerializer.Serialize(writer, scene, null);
            }
        }
    }
}
